<template>
<div class="card-password-Edit views-container">
    <div class="wlm-form">
        <div class="wlm-form-header"><span>您正在向 <span class="orders-blue">{{title}}</span> 添加串码</span>
        </div>
        <div class="wlm-form-content">
            <el-form ref="user" :model="formFormatData.formData" :rules="formFormatData.rules" size="small" label-width="140px" class="retail-form" label-position="right">
                <!-- <el-form-item label="核销码状态">
                    <el-radio-group v-model="formFormatData.formData.kammi_class">
                        <el-radio :label="1">待出售</el-radio>
                        <el-radio :label="2">仓库中</el-radio>
                    </el-radio-group>
                </el-form-item> -->
                <el-form-item label="生成数量">
                    <el-input placeholder="请输入生成数量" v-model.trim="formFormatData.formData.num">
                    </el-input>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input placeholder="请输入核销码备注" v-model.trim="formFormatData.formData.explain">
                    </el-input>
                </el-form-item>
            </el-form>
        </div>
    </div>
    <div v-cloak class="wlm-fixed-btn flex-row flex-align-c flex-justify-c">
        <el-button size="small" @click="saveDialogForm" type="primary">保存</el-button>
        <router-link tag="span" :to="{path:'/application/cardSerialCodeList', query :{ kammi_id: $route.query.kammi_id}}">
            <el-button size="small">返回</el-button>
        </router-link>
    </div>
</div>
</template>

<script>
import {
  keyVercodeAdd
} from '@/api/application'
import mixins from '@/mixins/mixins'
require('../../utils/vue-py.js')
export default {
  mixins: [mixins.getters('Form')],
  name: 'CardSerialCodeAdd',
  components: {
  },
  computed: {
  },
  created() {
    // kammiDetail({ kammi_id: this.$route.query.kammi_id }).then((response) => {
    //   const {
    //     data: {
    //       data: msgData = []
    //     }
    //   } = response
    //   this.categoryData = msgData.kammi_field
    //   this.title = msgData.kammi_title
    //   const keyValue = []
    //   this.categoryData.map((item, index) => {
    //     keyValue.push('')
    //   })
    //   this.formFormatData.formData.key_list.push({ key_value: keyValue })
    // })
  },
  data() {
    return {
      title: '',
      name: '',
      categoryData: [],
      formFormatData: {
        key: 'user',
        model: {
          noCreateEdit: false
        },
        api: {
          submitForm: keyVercodeAdd
        },
        formData: {
          kammi_id: this.$route.query.kammi_id,
          num: '',
          explain: ''
        }
      }
    }
  },
  methods: {
    delLibrary(index) {
      this.formFormatData.formData.key_list.splice(index, 1)
    },
    saveDialogForm() {
      this.formFormatSubmit({ router: { type: 'replace', path: '/application/cardSerialCodeList', code: 1, query: { kammi_id: this.$route.query.kammi_id } } })
    },
    addField() {
      const keyValue = []
      this.categoryData.map((item, index) => {
        console.log(item, 'item')
        console.log(index, 'index')
        keyValue.push('')
      })
      this.formFormatData.formData.key_list.push({ key_value: keyValue })
    }
  }
}
</script>

<style lang="scss" scoped>
.card-password-Edit {
    .logo {
        height: 40px;
        width: 40px;
        border-radius: 50%;
        vertical-align: middle;
        margin-right: 6px;
    }

    /deep/ .el-table__header thead .is-leaf {
        background-color: #f2f2f2 !important;
        text-align: center;
    }

    /deep/ .el-table__header thead .is-leaf {
        height: 32px;
        padding: 10px 0;
    }

}
</style>
